package cn.jiangxiong.pethome.system.user.service.impl;

import cn.jiangxiong.pethome.base.service.impl.BaseServiceImpl;
import cn.jiangxiong.pethome.system.user.domain.Employee;
import cn.jiangxiong.pethome.system.user.domain.EmployeeBo;
import cn.jiangxiong.pethome.system.user.domain.EmployeeRo;
import cn.jiangxiong.pethome.system.user.mapper.EmployeeMapper;
import cn.jiangxiong.pethome.system.user.service.IEmployeeService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
@Transactional(readOnly = true , propagation = Propagation.SUPPORTS)
public class EmployeeServiceImpl extends BaseServiceImpl<Employee> implements IEmployeeService {
   @Autowired
   private EmployeeMapper employeeMapper;

    @Override
    public List<Employee> findAll() {
        List<EmployeeBo> lists = employeeMapper.findAllBo();
        List<Employee> employeeList = new ArrayList<>();
        for (EmployeeBo list : lists) {
            Employee employee = new Employee();
            BeanUtils.copyProperties(list, employee);
            employeeList.add(employee);
        }
        return employeeList;
    }


    @Override
    public List<EmployeeRo> countByDate() {
        return employeeMapper.countByDate();
    }
}
